package com.envper.controller.repair;

import com.envper.common.domain.dto.RepairDto;
import com.envper.common.service.repair.RepairService;
import com.envper.mysql.domain.Result;
import com.envper.mysql.domain.Status;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/repair")
@RequiredArgsConstructor
public class RepairController {
    private final RepairService repairService;

    @PostMapping("/add")
    public Result<String> addRepair(@RequestBody RepairDto repairDto) {
        repairService.addRepair(repairDto);
        return Result.ok(Status.AddSuccess);
    }

    @GetMapping("/list")
    public Result<List<RepairDto>> getRepairList() {
        List<RepairDto> repairList = repairService.getRepairList();
        return Result.ok(Status.SUCCESS, repairList);
    }

}
